<template>
  <div class="search">
    <f-form ref="form" :action="api.sft" :form-key="this.formItem.fileTypeId" >
      <f-form-item label="类型名称"  name="typeName" dataType="${formField.dataType}"   :value="formItem.typeName" />
      <f-form-item label="编码类型"  name="contentType" dataType="${formField.dataType}"   :value="formItem.contentType" />
      <f-form-item label="是否允许转换PDF"  name="allowConvert" dataType="number"   :value="formItem.allowConvert" />
      <f-form-item label="是否允许OCR识别"  name="allowOcr" dataType="number"   :value="formItem.allowOcr" />
      <f-form-item label="是否允许上传"  name="state" dataType="number"   :value="formItem.state" />
      <f-form-item label="创建时间"  name="createTime" dataType="${formField.dataType}"   :value="formItem.createTime" />
      <f-form-item label="更新时间"  name="updateTime" dataType="${formField.dataType}"   :value="formItem.updateTime" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'sftForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          fileTypeId: '',
          typeName: '',
          contentType: '',
          allowConvert: '',
          allowOcr: '',
          state: '',
          createTime: '',
          updateTime: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.fileTypeId) {
          let params={
              fileTypeId:data.fileTypeId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
